package com.cxf.windex.rest;

import com.cxf.windex.base.msg.TableResultResponse;
import com.cxf.windex.base.rest.BaseRestController;
import com.cxf.windex.biz.CxfPayInfoBiz;
import com.cxf.windex.entity.CxfPayInfo;
import com.cxf.windex.entity.CxfUser;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @program: drp
 * @description: 支付信息
 * @author: chenxf
 * @create: 2018-05-22 16:39
 **/
@Api(tags = {"聚能小宝 - 支付詳情接口"})
@Controller
@RequestMapping("api_pay_info")
public class CxfPayInfoController extends BaseRestController<CxfPayInfoBiz,CxfPayInfo> {
    @ApiOperation(value="获取销售用户列表", notes="获取销售用户列表")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ResponseBody
    public TableResultResponse<CxfPayInfo> getInfo(@RequestParam(defaultValue = "10") int limit, @RequestParam(defaultValue = "1") int offset,
                                                @RequestParam(defaultValue = "desc") String orderStr,String name,String phone,String platformName){
        Example example = new Example(CxfPayInfo.class);
        Example.Criteria criteria = example.createCriteria();
      if(StringUtils.isNotBlank(name)){
        criteria.andLike("name","%" + name + "%");
      }
      if(StringUtils.isNotBlank(phone)){
        criteria.andLike("username","%" + phone + "%");
      }
      if (StringUtils.isNotBlank(platformName)) {
        criteria.andLike("platformName", "%" + platformName + "%");
      }
        example.setOrderByClause("addtime  desc");
      PageHelper.startPage(offset, limit);
        List<CxfPayInfo> items = baseBiz.selectByExample(example);

        PageInfo<CxfPayInfo> pageInfo = new PageInfo<CxfPayInfo>(items);
        return new TableResultResponse<CxfPayInfo>(Integer.parseInt(String.valueOf(pageInfo.getTotal())),
                offset, limit,
                items);
    }


}
